package com.cyj.dream.admin.service.system.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cyj.dream.admin.model.request.SysOperationLogQueryRequest;
import com.cyj.dream.admin.model.system.SysOperationLog;
import com.cyj.dream.admin.persistence.manager.systems.SysOperationLogManager;
import com.cyj.dream.admin.service.system.SysOperationLogService;
import com.cyj.dream.core.constant.pagemodel.PageParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description:
 * @BelongsProject: DreamChardonnay
 * @BelongsPackage: com.cyj.dream.core.service.impl
 * @Author: ChenYongJia
 * @CreateTime: 2021-10-25 13:54
 * @Email: chen87647213@163.com
 * @Version: 1.0
 */
@Slf4j
@Service
public class SysOperationLogServiceImpl implements SysOperationLogService {

    @Autowired
    private SysOperationLogManager sysOperationLogManager;

    /**
     * 分页查询系统操作日志信息
     *
     * @param pageParam 分页参数以及入参
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.dream.DreamChardonnay.model.system.SysOperationLog>
     * @date 2021/6/11 10:30
     * @author ChenYongJia
     * @version 1.0
     */
    @Override
    public IPage<SysOperationLog> list(PageParam<SysOperationLogQueryRequest> pageParam) {
        Page<SysOperationLog> page = new Page<>(pageParam.getPageNum(), pageParam.getPageSize());
        IPage<SysOperationLog> dbPage = sysOperationLogManager.list(page, pageParam.getParam());
        return dbPage;
    }


    /**
     * 添加系统操作日志
     *
     * @param sysOperationLog
     * @return com.dream.DreamChardonnay.model.system.SysOperationLog
     * @date 2021/4/2 9:52
     * @author ChenYongJia
     * @version 1.0
     */
    @Override
    public boolean addOperationLog(SysOperationLog sysOperationLog) {
        log.info("添加系统操作日志方法，接收到的参数为：{}", JSONObject.toJSONString(sysOperationLog));
        return sysOperationLogManager.addOperationLog(sysOperationLog);
    }

    /**
     * 删除本月、本周、今天之前的所有操作记录
     *
     * @param type 删除的日期阶段
     * @return boolean
     * @date 2021/6/21 11:26
     * @author ChenYongJia
     * @version 1.0
     */
    @Override
    public boolean deleteOperationLog(Integer type){
        log.info("删除本月、本周、今天之前的所有操作记录，接收到的参数为：{}", type);
        return false;
    }

}
